<template>
  <div class="cms-page">
    <h2 class="cms-title">
      欢迎您
      <span style="font-size: 14px">{{time}}</span>
    </h2>
  </div>
</template>

<script>
  /**
   * @Author: lifuzhao
   * @Date: 2019-05-14
   * @Project: eabax
   */
  export default {
    name: 'index',
    data() {
      return {
        time: ''
      }
    },
    mounted() {
      this.init()
    },
    methods: {
      init() {
        this.updateTime()
        setInterval(() => {
          this.updateTime()
        }, 1000)
      },
      updateTime() {
        let now = new Date(),
          date = now.getFullYear(),
          month = now.getMonth() + 1,
          day = now.getDate(),
          hour = now.getHours(),
          minute = now.getMinutes(),
          second = now.getSeconds()
        if (hour < 10) {
          hour = '0' + hour
        }
        if (minute < 10) {
          minute = '0' + minute
        }
        if (second < 10) {
          second = '0' + second
        }
        this.time = date + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
      }
    },
    layout: 'cms'
  }
</script>

<style scoped>

</style>
